* ======================================
* ----------- Import eucation ----------
* ======================================


	use "$dta_raw\dta9\W19_0078_BU_UTD.dta", clear
	rename w19 idPers

	
* Highest education obtained in 2015
* ==================================
	
	preserve
	keep idPers bu_2015 
	rename bu_2015 educ
	gen educlvl = substr(educ,1,1)
	destring educlvl, replace
	gen year = 2015
	
	tempfile educ2015
	save `educ2015'
	restore
	
	
* Highest education obtained in 2019
* ==================================

	preserve
	keep idPers bu_2019 
	rename bu_2019 educ
	gen educlvl = substr(educ,1,1)
	destring educlvl, replace
	gen year = 2019

	tempfile educ2019
	save `educ2019'
	restore

* Append in long format
* =====================

	clear
	append using `educ2015'
	append using `educ2019'
	
	drop if educlvl == . 			// missing
	drop if educlvl == 9 			// not classified
	gen hieduc = 1*(educlvl >= 6) 	// 6 = 1st stage of higher educ. (undergrad)

	sort idPers year
	save "$dta\ImportEduc.dta", replace